package Java学习.方法;

import java.util.Scanner;

public class 比较两个长方形的面积 {
    //1.方法一求出两个长方形的面积
    //2,比较
    public static void main(String[] args) {
        double[] num=new double[2];
        for (int i=0;i<=1;i++) {
            System.out.println("请输入第"+(i+1)+"个长方体的宽");
            Scanner sc = new Scanner(System.in);
            double weight = sc.nextDouble();
            System.out.println("请输入第"+(i+1)+"一个长方形的长");
            double height = sc.nextDouble();
            //求面积
            double S1=S(weight,height);
            num[i]=S1;
        }
        //比较
        System.out.println(P(num[0],num[1]));

    }
    public static double S(double wight,double height){
        double result=wight*height;
        return result;
    }
    //比较的方法
    public static String P(double S1,double S2){
        if (S1>S2){
            return S1+"第一个的面积大";

        }else {
            return S2+"第二个的面积大";
        }
    }
}
